<template>
    <div class="service">
        <div class="reserve-form">
            <div class="form-box">
                <div class="form">
                    <h1 class="title">天威测量预约</h1>
                    <el-form ref="form" :model="form">
                        <el-row :gutter="20">
                            <el-col :span="24" class="col">
                               <el-form-item label="">
                                    <el-input v-model="form.name" placeholder="您的姓名"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24" class="col">
                               <el-form-item label="">
                                    <el-input v-model="form.mobile" placeholder="您的手机号"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24" class="col">
                               <el-form-item label="">
                                    <el-input v-model="form.email" placeholder="公司邮箱"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24" class="col">
                               <el-form-item label="">
                                    <el-input v-model="form.company" placeholder="公司名称"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24" class="col">
                                <el-select v-model="form.money" placeholder="预约金额" style="width:100%">
                                <el-option label="区域一" value="jine1"></el-option>
                                <el-option label="区域二" value="jine2"></el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="24" class="col">
                                <el-select v-model="form.mall" placeholder="服务商场" style="width:100%">
                                <el-option label="区域一" value="shangchang1"></el-option>
                                <el-option label="区域二" value="shangchang2"></el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="24" class="col">
                                <el-input type="textarea" v-model="form.demand" placeholder="需求备注"></el-input>
                            </el-col>
                           
                            <el-col :span="24" class="col">
                                <el-checkbox v-model="checked1" class="check" >
                                    我已阅读并同意<a href="javascript:;" class="link">隐私政策</a>
                                </el-checkbox>
                            </el-col>
<!--                            <el-col :span="24" class="col">-->
<!--                                <el-checkbox v-model="checked2" class="check">-->
<!--                                    我同意天威将本人预约信息分享给XXX并接受天威满意度电话调研-->
<!--                                </el-checkbox>-->
<!--                            </el-col>-->
                             <el-col :span="24" class="col">
                                <el-button type="primary" class="btn" @click="tijiao">提交</el-button>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </div>
        </div>
        <div class="reason">
            <h3 class="reason-txt">选择天威设计的原因</h3>
            <div class="row">
                <div class="col" v-for="(item,index) in articleList" :key="index" style="cursor: pointer;"  @click="$navTo('/home/exhibitDetail?id='+item.id)">
                    <div class="reason-box">
                        <div class="img">
                            <img :src="'http://tianwei888.oss-cn-beijing.aliyuncs.com' + item.img_src" alt="">
                        </div>
                        <h3 class="name">{{item.title}}</h3>
                        <p class="desc">{{item.summary}}</p>
                    </div>
                </div>
            </div>
        </div>
        <div id="page" v-if="total > 1" style="display: flex;justify-content: center;padding: 20px 0;">
            <el-pagination
                layout="prev, pager, next"
                :current-page="page"
                @current-change="nextPage"
                :page-size="num"
                :total="total">
            </el-pagination>
        </div>
        <Footers />
    </div>
</template>
<script>
import Footers from "../home/components/footer.vue"
import request from "../../utils/request";
export default{
    data(){
        return{
            form:{
                type:2,
                name:'',
                mobile:'',
                company:'',
                email:'',
                money:'',
                mall:'',
                demand:''
            },
            checked1:false,
            checked2:true,
            category:{},
            articleList:[],
            page:1,
            num:5,
            total:null
        }
    },
    created() {
        this.id = this.$route.query.id
        this.getArticle()
        this.getCategory()

    },
    methods:{
        tijiao(){
            request.post('/market/enroll',{...this.form}).then(res=>{
                this.$message({type:'success',message: res.msg})
                this.form = {
                    type:2,
                    name:'',
                    mobile:'',
                    company:'',
                    email:'',
                    money:'',
                    mall:'',
                    demand:''
                }
            })
        },
        getCategory(){
            request.post('/article/getArticleCategoryDetail',{id:this.id}).then(res=>{
                this.category = res.data
            })
        },
        getArticle(){
            request.post('/article/getArticleList',{type:this.id,page:this.page,num:this.num}).then(res=>{
                this.articleList = res.data.list
                this.total = res.data.total
            })
        },
        nextPage(i){
            this.page = i
            this.getArticle()
        }
    },
    components:{
        Footers,
    }
}
</script>
<style lang="scss">
.service{
    .el-form-item{margin-bottom: 0;}
    .reserve-form{
    position: relative;
    background: url("https://m2.ikea.cn/images/43/78/43789358d695d6a682159efb33f88286.jpg") no-repeat center center;
    width: 100%;
    height: 800px;
    background-size: cover;
    .form-box{
        max-width: 1200px;
        height: 100%;
        margin: 0 auto;
        position: relative;
        .form{
            width: 500px;
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            background: #fff;
            border-radius: 20px;
            padding: 20px 40px;
            .title{
                font-size: 24px;
                font-weight: 600;
                margin: 0;
                margin-bottom: 30px;
                text-align: center;
            }
            .col{
                margin-bottom: 20px;
                cursor:pointer;
            }
            .label{
                font-size: 14px;
                color: #333;
                margin-bottom: 5px;
            }
            .input{
                border: none;
                width: 100%;
                height: 30px;
                line-height: 30px;
                border-bottom: 1px solid #aeaeae;
                padding-left: 5px;
                font-size: 14px;
            }
            .check {
                font-size: 12px;
                .el-checkbox__label{
                    font-size: 12px !important;
                    color: #999 !important;
                    font-weight: 400 !important;
                    .link{
                        color: #409eff;
                    }
                }
            }
            .btn{
                border-radius: 40px;
                width: 90%;
                margin: 0 auto;
                display: block;
                background: #000;
                color: #fff;
                border: none;
            }
        }
    }
}
.reason{
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 20px;
    .reason-txt{
        font-size: 16px;
        color: #444;
        font-weight: 600;
        margin-bottom: 30px;

    }
    .row{
        display: flex;
        .col{
            width: calc(20% - 12px);
            margin-right: 15px;
            &:nth-child(5n){margin-right: 0;}
            margin-bottom: 20px;
            .reason-box{
                .img{
                    img{width: 100%; height: auto;}
                }
                .name,.desc{margin: 0;}
                .name{
                    font-size: 18px;
                    color: #111;
                    line-height: 28px;
                    margin-bottom: 5px;
                }
                .desc{font-size: 14px;color: #888;}
            }
        }
    }
}
}
</style>